﻿using UnityEngine;
using System.Collections;

public class Player_t : MonoBehaviour {

    public float timer = 0;
    public int frameCount = 0;
    public int frameNumber = 10;
    private Rigidbody r;

    void Start()
    {
        r = GetComponent<Rigidbody>();
        r.velocity = new Vector3(2,0,0);

    }

    void Update()
    {
        timer += Time.deltaTime;
        if (timer >= 1.0f / frameNumber)
        {
            frameCount++;
            timer -= 1.0f / frameNumber;
            int frameIndex = frameCount % 3;
            GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0.3f * frameIndex, 0));
        }
        if(Input.GetMouseButton(0)){
            Vector3 v = r.velocity;
            r.velocity = new Vector3(v.x, 1.5f, 0);
        }
    }
}

